package com.example.day02.home;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.example.day02.R;

import java.util.ArrayList;
import java.util.List;
//引导界面

public class GuideActivity extends AppCompatActivity {
    ViewPager guideVp;
    int[]imgIds={R.mipmap.loading1,R.mipmap.loading2,R.mipmap.loading3};
    List<ImageView>imgList;
    private GuidePagerAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guide);
        guideVp=findViewById(R.id.guide_vp);
        imgList=new ArrayList<>();//Vp的数据源
        for (int i = 0; i < imgIds.length; i++) {
            ImageView iv = new ImageView(this);
            iv.setImageResource(imgIds[i]);
            iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
            LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
            iv.setLayoutParams(lp);
            imgList.add(iv);
            //创建适配器
            adapter = new GuidePagerAdapter(this, imgList);
            //设置适配器
            guideVp.setAdapter(adapter);
        }
    }
}
